<?php
session_start();
include "/tablas/util.php";

$dateTime = new DateTime();
$dateTime->modify('first day of this month');
$fecha_desde = $dateTime->format('Y-m-d 00:00:00');
$fecha_hasta = util::FechaActual();
$fechas = $fecha_desde . "/" . $fecha_hasta;
?>
<script>
    fechas = <?php echo json_encode($fechas); ?>;
</script>
<html lang="es">
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <?php include "/header.php"; ?>
        <!--En cada formulario importaremos el respectivo js para realizar las respectivas funciones-->
        <!--CRUD-->
        <script src="js/realizarFactura.js"></script>
    </head>
    <script>
    </script>

    <body>
        <div id="BUENO " class="modal fade"><div class="modal-dialog"><div class="modal-content"></div></div></div>
      <nav class="navbar navbar-default">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="index.php">Inicio</a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <nav class="navbar navbar-default">
                    <div class="container-fluid">
                        <!-- Brand and toggle get grouped for better mobile display -->
                        <div class="navbar-header">
                            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                                <span class="sr-only">Toggle navigation</span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
                            <a class="navbar-brand" href="index.php">Inicio</a>
                        </div>

                        <!-- Collect the nav links, forms, and other content for toggling -->
                        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                            <ul class="nav navbar-nav">

                                <?php
                                $rol_name = isset($_SESSION["rol_descripcion"]) ? $_SESSION["rol_descripcion"] : null;
                                if (util:: getMenuAdministracionGestionUsuarios($rol_name)) {
                                    ?>

                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Gestion Usuarios <span class="caret"></span></a>
                                        <ul class="dropdown-menu" role="menu">

                                            <li><a href="usuarios.php">Registrar Usuarios</a></li>
                                            <li><a href="roles.php">Crear Roles</a></li>
                                            <li><a href="usuarios_roles.php">Asiganr Roles a Usuarios</a></li>
                                            <li><a href="roles_tareas.php">Asignar Permisos (Segun Roles)</a></li>
                                        </ul>
                                    </li>

                                <?php }
                                ?>
                                <?php
                                $rol_name = isset($_SESSION["rol_descripcion"]) ? $_SESSION["rol_descripcion"] : null;
                                if (util:: getMenuAdministracionGestionUsuarios($rol_name)) {
                                    ?>
                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Gestion Productos <span class="caret"></span></a>
                                        <ul class="dropdown-menu" role="menu">
                                            <li><a href="producto.php">Ingresar Productos</a></li>
                                            <li><a href="producto_stock.php">Stock de Productos</a></li>
                                        </ul>
                                    </li>
                                <?php }
                                ?>
                                <?php
                                $rol_name = isset($_SESSION["rol_descripcion"]) ? $_SESSION["rol_descripcion"] : null;
                                if (util:: getMenuAdministracionGestionUsuarios($rol_name)) {
                                    ?>
                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Gestion Compras <span class="caret"></span></a>
                                        <ul class="dropdown-menu" role="menu">
                                            <li><a href="proveedor.php">Ingresar Proveedores</a></li>
                                        </ul>
                                    </li>
                                <?php }
                                ?>
                                <?php
                                $rol_name = isset($_SESSION["rol_descripcion"]) ? $_SESSION["rol_descripcion"] : null;
                                if (util:: getMenuAdministracionGestionUsuarios($rol_name) || util::getMenuAdministracionGestionVendedores($rol_name)) {
                                    ?>
                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Gestion Ventas <span class="caret"></span></a>
                                        <ul class="dropdown-menu" role="menu">
                                            <li><a href="cliente.php">Registrar Clientes</a></li>
                                            <li><a href="ventas.php">Registrar Ventas</a></li>
                                            <li><a href="realizarFactura.php">Facturacion</a></li>

                                        </ul>
                                    </li>

                                <?php }
                                ?>
                                <?php
                                $rol_name = isset($_SESSION["rol_descripcion"]) ? $_SESSION["rol_descripcion"] : null;
                                if (util:: getMenuAdministracionGestionUsuarios($rol_name)||util:: getMenuAdministracionGestionSupervisore($rol_name)) {
                                    ?>
                                    <li class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Reportes <span class="caret"></span></a>
                                        <ul class="dropdown-menu" role="menu">
                                            <li><a href="reporteProductosAgotados.php">Productos Agotados</a></li>
                                            <li><a href="reporteVentasProductosFechas.php">Productos Vendidos por Fecha</a></li>
                                            <li><a href="usuarioVentasReporte.php">Ventas por Usuario</a></li>

                                        </ul>
                                    </li>
                                <?php }
                                ?>
                            </ul>

                            <ul class="nav navbar-nav navbar-right">
                                <li class="dropdown ">
                                    <a href="#" class="dropdown-toggle link-current-user" data-toggle="dropdown">
                                        <img src="/fv/themes/truulo/images/demo/avatar1_small.jpg" alt="">
                                        <span class="username"><?php echo (isset($_SESSION["session_username"]) && $_SESSION["session_username"]) ? $_SESSION["session_username"] : "Invitado" ?></span>
                                        <b class="caret"></b>
                                    </a>

                                    <ul class="dropdown-menu extended logout">
                                        <?php if ((isset($_SESSION["session_username"]) && $_SESSION["session_username"])) { ?>
                                            <li><a href="cerrarsesion.php"><i class="icon-key"></i>&nbsp;&nbsp;Cerrar Sesión</a></li>
                                        <?php } else {
                                            ?>
                                            <li><a href = "login.php"><i class = "icon-key"></i>&nbsp;&nbsp;
                                                    Iniciar Sesion</a></li>
                                        <?php } ?>

                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>

            </div>
        </nav>


        <div class="col-md-12">
            <div class="panel panel-success">

                <div class="panel-body">
                    <div class="col-md-4">
                        <div class="panel panel-warning">
                            <div class="panel-heading">
                                <h3 class="panel-title">Datos Factura</h3>
                            </div>
                            <div class="panel-body">
                                <form class="form-horizontal" id="datos_cliente-form" action="#" method="post"> 
                                    <div class="form-group"><label class="col-sm-3 control-label required" for="Factura_cliente_id">Cliente<span class="required">*</span></label><div class="col-sm-9"><input class="form-control"  name="Factura[id_cliente]" required id="Factura_id_cliente" type="text" maxlength="45"><div class="help-block error" id="Factura_id_cliente_em_"   style="display:none"></div></div></div>                                            
                                    <div class="form-group"><label class="col-sm-3 control-label required" for="Factura_fecha_emision">Fecha Emision<span class="required"></span></label><div class="col-sm-9"><input class="form-control" placeholder="Fecha Emision" name="Factura[fecha_emision]" required id="Factura_fecha_emision"  maxlength="45"><div class="help-block error" id="Factura_fecha_emision_em_"   style="display:none"></div></div></div>                                            
                                    <div class="form-group"><label class="col-sm-3 control-label required">Cedula<span class="required"></span></label><div class="col-sm-9"><input class="form-control" id="cliente_cedula" type="text" maxlength="45"><div class="help-block error" style="display:none"></div></div></div>                                            
                                    <div class="form-group"><label class="col-sm-3 control-label required">Nombre y Apellido<span class="required"></span></label><div class="col-sm-9"><input class="form-control" id="cliente_nombre_apellido" type="text" maxlength="45"><div class="help-block error" style="display:none"></div></div></div>                                            
                                    <div class="form-group"><label class="col-sm-3 control-label required">Direccion<span class="required"></span></label><div class="col-sm-9"><input class="form-control" id="cliente_direccion" type="text" maxlength="45"><div class="help-block error" style="display:none"></div></div></div>                                            
                                    <div class="form-group"><label class="col-sm-3 control-label required">Telefono<span class="required"></span></label><div class="col-sm-9"><input class="form-control" id="cliente_telefono" type="text" maxlength="45"><div class="help-block error" style="display:none"></div></div></div>                                            
                                    <div class="form-group"><label class="col-sm-3 control-label required">Celular<span class="required"></span></label><div class="col-sm-9"><input class="form-control" id="cliente_celular" type="text" maxlength="45"><div class="help-block error" style="display:none"></div></div></div>                                            

                                    <footer>
                                        <div class="  col-lg-offset-4">
                                            <!--<button class="btn btn-primary btn btn-default" id="usuariosBtnCrear" >Crear</button>-->                      
                                            <!--<p><a id="getInfo" class="btn btn-primary btn-lg" href="#" role="button">Funcion Ajax</a></p>-->
                                            <button class="btn btn-default" id="btn_save_factura" onclick="js:insertarFacturas('#facturas-form')" name="yt1" type="button" >Agregar</button>
                                            <!--<button class="btn btn-primary btn btn-default" id="btn_save_imagen" name="yt0" type="button">Registrar</button>-->
                                            <!--<button class="btn btn-default" id="yw1" name="yt1" type="button">Cancelar</button>-->
                                        </div>

                                    </footer>
                                </form>
                            </div>                        


                        </div>
                    </div>
                    <div class="col-md-8">
                        <div class="panel panel-info">
                            <div class="panel-heading">
                                <h3 class="panel-title"> Detalle Factura</h3>
                            </div>
                            <div class="panel-body">
                                <div role="content" style="display: block;">

                                    <!-- widget edit box -->
                                    <div class="jarviswidget-editbox">
                                        <!-- This area used as dropdown edit box -->

                                    </div>
                                    <!-- end widget edit box -->

                                    <!-- widget content -->
                                    <div class="widget-body">
                                        <div id="detalles" class="widget-body form">
                                            <div style="max-height: 320px;overflow: auto;">
                                                <table id="factura" class="items table table-striped table-bordered table-hover table-advance table-condensed">
                                                    <thead>
                                                        <tr>
                                                            <th id="orden-compra-grid_c7">Codigo </th>
                                                            <th id="orden-compra-grid_c0">Producto</th>
                                                            <th id="orden-compra-grid_c1">Precio </th>
                                                            <th id="orden-compra-grid_c8">Desc </th>
                                                            <th style="width:80px" id="orden-compra-grid_c2">Cantidad</th>
                                                            <th id="orden-compra-grid_c3">SubTotal</th>
                                                            <th id="orden-compra-grid_c4">IVA</th>
                                                            <th id="orden-compra-grid_c5">Total</th>
                                                            <th class="button-column" id="orden-compra-grid_c6">&nbsp;</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <!-- CONTENIDO DE LA TABLA -->
                                                    <input name="VentasFactura[id]" id="VentasFactura_id" type="hidden">                    </tbody>
                                                </table>
                                            </div>
                                            <div class="space20"></div>
                                            <div class="row-fluid">
                                                <a href="#mainModal" role="button" class="btn btn-primary" data-toggle="modal" id="agregarProducto"><i class="icon-plus icon-white"></i> Agrega Producto</a>

                                                <hr>
                                                <div class="span5 invoice-block pull-right">
                                                    <ul class="unstyled " style="text-align: left; ">
                                                        <li>  Subtotal sin Descuento:  <div class="pull-right">$ <span id="subtotalSinDescuento">0.00</span></div> </li>
                                                        <li><a href="#mainModal" data-toggle="modal" id="descuentoGeneral">  Descuento :</a>  <div class="pull-right">$ <span id="descuentoTotal">0.00</span></div> </li>
                                                         <!--<li>  Descuento :  <div class="pull-right">$ <span id="descuentoGeneral">0</span></div> </li>-->

                                                        <li>  Subtotal:  <div class="pull-right">$ <span id="subtotal">0.00</span></div> </li>
                                                        <li>  Tarifa 0%:  <div class="pull-right">$ <span id="ivaCero">0.00</span></div> </li>
                                                        <li>  Tarifa 12%:  <div class="pull-right">$ <span id="ivaDoce">0.00</span></div> </li>
                                                        <li>  No Objeto Iva :  <div class="pull-right">$ <span id="noIva">0.00</span></div> </li>
                                                    </ul>
                                                    <hr>
                                                    <ul class="unstyled amounts" style="text-align: left;">
                                                        <li><strong>IVA 12%:</strong><div class="pull-right">$ <span id="ivaTotal">0.00</span></div> </li>
                                                        <li><strong>Total :</strong><div class="pull-right">$ <span id="total">0.00</span></div> </li>
                                                    </ul>
                                                    <input id="descuentosGenerales" type="hidden" class="input-mini" value="0">
                                                    <input id="descuentosGeneralesPorcentaje" type="hidden" class="input-mini" value="0">

                                                </div>
                                            </div>
                                        </div>        </div>
                                    <!-- end widget content -->

                                </div>
                                <!-- end widget div -->

                            </div>
                        </div>                        


                    </div>
                </div>
            </div>
        </div>
    </div>




</body>

</html>
